﻿/**
 * Copyright (C) 2011 original author and authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NGuice.Inject
{
    /// <summary>
    /// 由于C#泛型没有通配符，因此使用此标记接口解决泛型通配符问题。
    /// <remarks>
    /// 通常认为一个注入器包含的可注入成员是泛型参数T的子类，但事实并非如此。这个问题和依赖倒置一样，可注入器
    /// 包含的成员注入列表，是泛型T参数的超类！因为只有超类成员，才允许子类T的注入赋值！
    /// </remarks>
    /// </summary>
    public interface IMembersInjector
    {
        void InjectMembers(object instance);
    }

    /// <summary>
    /// 注入指定实例依赖的域和方法。他将忽略存在或不存在的可注入的构造器
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IMembersInjector<T>
    {
        /// <summary>
        /// 注入指定实例依赖的域和方法。他将忽略存在或不存在的可注入的构造器
        /// 无论NGuice是否创建一个实例，他都自动执行此注入（在第一次执行构造注入后），因此如果你让
        /// NGuice为你创建所有你的对象，你永远无需使用此方法
        /// </summary>
        /// <param name="instance">要注入成员的实例</param>
        void InjectMembers(T instance);
    }
}
